﻿<Window x:Class="Scripni.EditPathVariable.UI.MainWindow"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
		DataContext="{Binding Source={StaticResource Locator}, Path=Main}"
		Title="Edit PATH Variable"
		Height="350"
		Width="525">
	<i:Interaction.Triggers>
		<i:EventTrigger EventName="Loaded">
			<i:InvokeCommandAction Command="{Binding LoadData}" />
		</i:EventTrigger>
	</i:Interaction.Triggers>
	<Window.CommandBindings>
		<CommandBinding Command="Close"
						Executed="CommandBinding_Executed" />
	</Window.CommandBindings>
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>
		<Menu Height="23"
			  HorizontalAlignment="Stretch"
			  Name="menu1"
			  Grid.Row="0"
			  VerticalAlignment="Top">
			<MenuItem Header="_File">
				<MenuItem Header="_Save"
						  Command="{Binding SaveData}" />
				<MenuItem Header="_Refresh"
						  Command="{Binding LoadData}" />
				<MenuItem Header="E_xit"
						  Command="Close" />
			</MenuItem>
			<MenuItem Header="_Tools">
				<MenuItem Header="Add from _directory"
						  Command="{Binding AddPathFromDirectory}" />
                <MenuItem Header="_Export to CSV"
                          Command="{Binding ExportToCsv}" />
            </MenuItem>
			<MenuItem Header="_Options">
				<MenuItem Header="On _save">
					<MenuItem Header="_Remove duplicates"
							  IsCheckable="True"
							  IsChecked="{Binding RemoveDuplicates}" />
				</MenuItem>
			</MenuItem>
			<MenuItem Header="_Help">
				<MenuItem Header="_About"
						  Click="MenuItem_Click" />
			</MenuItem>
		</Menu>
		<DataGrid ItemsSource="{Binding Paths}"
				  AutoGenerateColumns="False"
				  Grid.Row="1"
				  HorizontalAlignment="Stretch"
				  VerticalAlignment="Stretch"
				  Margin="12"
				  Name="gridPaths">
			      <DataGrid.Resources>
        <Style x:Key="errorStyle" TargetType="{x:Type TextBox}">
          <Setter Property="Padding" Value="-2"/>
          <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="True">
              <Setter Property="Background" Value="Red"/>
              <Setter Property="ToolTip" 
                Value="{Binding RelativeSource={RelativeSource Self},
                  Path=(Validation.Errors)[0].ErrorContent}"/>
            </Trigger>
          </Style.Triggers>
        </Style>
      </DataGrid.Resources>
			<DataGrid.Columns>
				<DataGridTextColumn Header="Path"
									Binding="{Binding Name, ValidatesOnDataErrors=True}" />
			</DataGrid.Columns>
		</DataGrid>
	</Grid>
</Window>
